package LeetCode刷题;

/**
 * @program: Java_Study
 * @author: Xiaofan
 * @createTime: 2021-11-13 20:48
 * @description: Functions of this class is
 *
 **/
public class No环形链表 {
    public static void main(String args[]){

    }
    /**
     * public boolean hasCycle(ListNode head) {
     * 哈希表做法：
     *         ListNode<
     *         while(head!=null){
     *             if(set.contains(head)){
     *                 return true;
     *             }
     *             set.add(head);
     *             head=head.next;
     *         }
     *         return false;
     *     }
     * （快慢指针）：
     * public class Solution {
     *     public boolean hasCycle(ListNode head) {
     *         if(head==null||head.next==null){
     *             return false;
     *         }
     *         ListNode slow=head;
     *         ListNode fast=slow.next.next;
     *         while(fast!=null&&fast.next!=null){
     *             if(slow==fast){
     *                 return true;
     *             }
     *             slow=slow.next;
     *             fast=fast.next.next;
     *         }
     *         return false;
     *     }
     * }
     *
     */
}